<template>
  <div>
    <div class="cent">
      <div class="login-size">登录</div>
      <div style="height: 1px;width: 100%;background: #eee"></div>
      <div style="margin-top: 15px;">
        <el-tag style="height: 25px;line-height: 24px;">账号</el-tag>
        <el-input placeholder="请输入内容" maxlength="11" v-model="account" type="text"></el-input>
      </div> 
      <div style="margin-top: 10px;">
        <el-tag style="height: 25px;line-height: 24px;">密码</el-tag>
        <el-input placeholder="请输入密码" v-model="password" type="password"></el-input>
      </div>
      <div>
        <el-row>
          <el-button @click="login" type="primary" style="width: 100%; margin-top: 20px;" plain>登录</el-button>
        </el-row>
      </div>
    </div>
  </div>
</template>
<script>
import { close_loading, open_loading } from '@/utils/message';
import { logins } from '@/api/login';
import { set_token } from '@/utils/auth'


export default {
    data: () => {
        return {
            account: '15570820928',
            password: '123456'
        }
    },
    methods: {
        async login() {
            open_loading("登录中...");

            const res = await logins({
                account: this.account,
                password: this.password
            });
            close_loading();
            if (res.code === 0) { 
                set_token(res.data);
                this.$router.push('/');
                // location.href = '/';
            } else {
                this.$message.error(res.message);
            }


            // axios.post("http://localhost:54862/api/login/logins", {
            //     account: this.account,
            //     password: this.password
            // }).then((res) => {
            //     close_loading();
            //     console.log(res, "::::");

            //     if (res.data.code === 0) {
            //         set_token(res.data.data);
            //         //将用户信息存入到缓存中
            //         this.$router.push('/');
            //         // this.$message.success(res.message);
            //     } else {
            //         this.$message.error(res.data.message);
            //     }

            // });

        }
    },
    components: {

    }
}
</script>
<style>
.cent {
  width: 350px;
  height: 300px;
  border: 1px solid #eee;
  padding: 10px;
}

.login-size {
  color: #409eff;
  font-size: 30px;
  text-align: center;
  margin-bottom: 10px;
}
</style>